package mobi.hami.huapin.dao;

import java.util.List;

import mobi.hami.huapin.daobase.CrudMapper;
import mobi.hami.huapin.model.SkuProductattributeMapping;
import mobi.hami.huapin.model.SkuProductattributeMappingExample;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

@Repository
public interface SkuProductattributeMappingMapper extends CrudMapper<SkuProductattributeMapping> {
    @Select("<script>"
            + "SELECT * FROM sku_productattribute_mapping "
            + "<where>"
            + "<if test='_parameter >0'>AND skuid = #{_parameter} </if>"
            + "</where>"
            + "</script>")
    List<SkuProductattributeMapping> selectAttribute_mapping(int skuid);

    @Delete("delete from sku_productattribute_mapping where skuid=#{skuid}")
    int DeleteAll(int skuid);

    /**
     *  返回 sku attribute mapping
     * @param skuid
     * @return
     */
    @Select("SELECT skuid, productattributeid,productattributevalueid FROM sku_productattribute_mapping where  skuid = #{skuid} order by displayorder asc")
    List<SkuProductattributeMapping> getMappingForSku(int skuid);

}